 <!-- Example table --> <div class="container_12"> 
      <div class="module">
                     <h2><span><?php echo $_title;?></span></h2>
                        
                     <div class="module-body">
                         <div style="margin-top:13px;">
                        <?php
                        if(isset($errMsg)){?>
                        <span class="notification"><?php echo $_MESSESGE[$errMsg];?></span>
                        <?php }?></div>
                        
                        <form id="adminForm" name="adminForm" action="" method="post">
                        
                            <p>
                                <label>Role Name<span class="star">*</span></label>
                                <div id="availability_info_loginid"></div>                                
                                <input type="text" class="input-short" name="group_name" id="group_name" value="<?php echo $result['group_name'];?>" />
                                <!-- <span class="notification-input ni-correct">This is correct, thanks!</span> -->
                            </p>
                            
                            <p>
                                <label>Assign Modules</label>
                                <table style="border-bottom: 0px;">
                                <?php
                                    $resMods = CommonUtility::getData($parms=null, $table='admin_modules', $condition=array('status'=>'1', 'visible_in_access_module' =>'1'));
                                    $i = 0;                                    
                                    $modid = array();
                                    foreach( $result['module_id'] as $val ){
                                        $tmp = explode('::', $val);
                                        $modid[$tmp[0]] = $tmp[1];
                                    }                                    
                                    foreach( $resMods as $row ){
                                        print($i%4==0 ? '</tr><tr>' : '');                                        
                                        echo '<td>';
                                        if( @array_key_exists($row['id'], $modid)){
                                            echo '&nbsp;&nbsp;<input type="checkbox" name="module_id[]" value="'.$row['id'].'" checked>&nbsp;'.$row['module_name'];
                                        }else{
                                            echo '&nbsp;&nbsp;<input type="checkbox" name="module_id[]" value="'.$row['id'].'">&nbsp;'.$row['module_name'];
                                        }
                                        $accessLevel = array();
                                        if($modid[1]!='')
                                            $accessLevel = explode('-',$modid[$row['id']]);
                                        //$sel = @in_array('1', $accessLevel) ? 'checked' : '';
                                        //echo '<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="op_'.$row['id'].'[]" value="1" '.$sel.'>&nbsp;List';
                                        $sel = @in_array('2', $accessLevel) ? 'checked' : '';
                                        echo '<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="op_'.$row['id'].'[]" value="2" '.$sel.'>&nbsp;Add';
                                        $sel = @in_array('3', $accessLevel) ? 'checked' : '';
                                        echo '<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="op_'.$row['id'].'[]" value="3" '.$sel.'>&nbsp;Edit';
                                        $sel = @in_array('4', $accessLevel) ? 'checked' : '';
                                        echo '<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="op_'.$row['id'].'[]" value="4" '.$sel.'>&nbsp;Delete';
                                        $i++;       
                                        echo '</td>';                                 
                                    }
                                    print($i%4==0 ? '</tr>' : ($i%4==3 ? '<td></td>' : ($i%4==2 ? '<td></td><td></td>' : '<td></td><td></td>' ) ) );
                                ?>
                                </table>
                            </p>
                           
                            <fieldset>
                                <input class="submit-green" type="submit" name="submit" value="Submit" /> 
                                <input class="submit-gray" type="button" value="Cancel" onclick="javascript: window.location='<?php echo _SITE_ADMIN_URL_?>'+'wedding/wedding_slab_mng.php';" />
                            </fieldset>
                        </form>
                     </div> <!-- End .module-body -->

                </div>  <!-- End .module -->
                </div>
                <div style="clear:both;"></div>
                
<script type="text/javascript">
$().ready(function() {
    var root_path = '<?php echo _SITE_ADMIN_URL_?>';
    var table = 'access_group';
    var field = 'group_name';
    var item_col = 'id';
    var item_value = '<?php echo $_REQUEST['id'];?>';
    $('#group_name').keyup(function(){ 
            var field_value = $(this).val();
            path = root_path+'ajax/getGeo.php?type=check_availability&table='+table+'&field='+field+'&field_value='+field_value+'&item_col='+item_col+'&item_value='+item_value;            
            $.ajax({url: path,    
                success: function(response) {
                    $('#availability_loading').hide();            
                    $('#availability_info_loginid').html(response);
                }
            });
        });
    
    $("#adminForm").validate({
        rules: {
            group_name: "required"
        },
        messages: {
            group_name: "Please enter Role name."
        }
    });
    
    $("input:checkbox[name='module_id[]']").click(function(){        
        var ctrl = 'op_'+this.value+'[]';    
        
        if( this.checked) {  // check all subbordinates            
            $('input:checkbox[name='+ctrl+']').each(function(){                
                this.checked = "checked";
            });
            
        }else{              // uncheck all subbordinates
            $('input:checkbox[name='+ctrl+']').each(function(){                
                this.checked = false;
            });            
        }
    });
});
</script>                